package org.xingyun.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.xingyun.bean.Provinces;
import org.xingyun.utils.DataSourcesUtils;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

public class ProvinceDao {
    public List<Provinces> getAll() throws SQLException {
        System.out.println("查询MySQL数据了");
        DataSource dataSource = DataSourcesUtils.getDataSource();
        QueryRunner queryRunner = new QueryRunner(dataSource);
        List<Provinces> list = queryRunner.query("select * from provinces", new BeanListHandler<Provinces>(Provinces.class));
        return list;
    }
}
